package cz.results.winter6.test;

import com.db4o.*;
import com.db4o.config.*;
import java.util.GregorianCalendar;


public class MyCalendar implements ObjectConstructor{
    
    public Object onInstantiate(ObjectContainer container, Object storedObject) {
        Long milliseconds = (Long)storedObject;
        //System.out.println("read millis:"+milliseconds);
        GregorianCalendar gc = new GregorianCalendar(2006,06,17,0,0,0);
        gc.setTimeInMillis(milliseconds);
        //System.out.println("read millis:"+gc.getTimeInMillis());
        return gc;
    }
    
    public Object onStore(ObjectContainer container, Object applicationObject) {
        GregorianCalendar gc = (GregorianCalendar)applicationObject;
        //System.out.println("write millis:"+gc.getTimeInMillis());
        return new Long(gc.getTimeInMillis());
    }
    
    public void onActivate(ObjectContainer container,
            Object applicationObject,
            Object storedObject) {
        // do nothing
    }
    
    public Class storedClass() {
        return long.class;
    }
    
}


